package com.anyou.mall.sho.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.anyou.mall.sho.domain.CarPartsShopAudit;
import com.anyou.mall.sho.param.IsPassCarPartsShopAuditParam;
import com.anyou.mall.sho.service.ICarPartsShopAuditService;
import com.anyou.mall.sho.vo.CarPartsShopAuditListVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 汽配商入住审核Controller
 *
 * @author gaochaohao
 * @date 2022-03-18
 */
@Api(tags = "商家入住审核")
@RestController
@RequestMapping("/sho/carPartsShopAudit")
public class CarPartsShopAuditController extends BaseController
{
    @Autowired
    private ICarPartsShopAuditService carPartsShopAuditService;

    /**
     * 查询汽配商入住审核列表
     */
    @ApiOperation("查询汽配商入住审核列表")
    @PreAuthorize("@ss.hasPermi('sho:carPartsShopAudit:list')")
    @GetMapping("/list")
    public TableDataInfo<List<CarPartsShopAuditListVo>> list(CarPartsShopAudit carPartsShopAudit)
    {
        startPage();
        List<CarPartsShopAuditListVo> list = carPartsShopAuditService.selectCarPartsShopAuditList(carPartsShopAudit);
        return getDataTable(list);
    }

    /**
     * 导出汽配商入住审核列表
     */
    @ApiOperation("导出汽配商入住审核列表")
    @PreAuthorize("@ss.hasPermi('sho:carPartsShopAudit:export')")
    @Log(title = "入住审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarPartsShopAudit carPartsShopAudit)
    {
        List<CarPartsShopAuditListVo> list = carPartsShopAuditService.selectCarPartsShopAuditList(carPartsShopAudit);
        ExcelUtil<CarPartsShopAuditListVo> util = new ExcelUtil<CarPartsShopAuditListVo>(CarPartsShopAuditListVo.class);
        util.exportExcel(response, list, "汽配商入住审核数据");
    }

    /**
     * 获取汽配商入住审核详细信息
     */
    @ApiOperation("入住审核详细信息")
    @PreAuthorize("@ss.hasPermi('sho:carPartsShopAudit:query')")
    @GetMapping(value = "/{carPartsShopAuditId}")
    public ApiResult<CarPartsShopAuditListVo> getInfo(@PathVariable("carPartsShopAuditId") Long carPartsShopAuditId)
    {
        return ApiResult.success(carPartsShopAuditService.selectCarPartsShopAuditDetailsByCarPartsShopAuditId(carPartsShopAuditId));
    }

    /**
     * 新增汽配商入住审核
     */
    @ApiOperation("新增商家入住审核")
    @PreAuthorize("@ss.hasPermi('sho:carPartsShopAudit:add')")
    @Log(title = "商家入住审核", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody CarPartsShopAudit carPartsShopAudit)
    {
        return ApiResult.success(carPartsShopAuditService.insertCarPartsShopAudit(carPartsShopAudit));
    }

    /**
     * 修改汽配商入住审核
     */
    @ApiOperation("修改商家入住审核")
    @PreAuthorize("@ss.hasPermi('sho:carPartsShopAudit:edit')")
    @Log(title = "商家入住审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody CarPartsShopAudit carPartsShopAudit)
    {
        return ApiResult.success(carPartsShopAuditService.updateCarPartsShopAudit(carPartsShopAudit));
    }

    /**
     * 删除汽配商入住审核
     */
    @ApiOperation("删除商家入住审核")
    @PreAuthorize("@ss.hasPermi('sho:carPartsShopAudit:remove')")
    @Log(title = "商家入住审核", businessType = BusinessType.DELETE)
    @DeleteMapping("/{carPartsShopAuditIds}")
    public ApiResult remove(@PathVariable Long[] carPartsShopAuditIds)
    {
        return ApiResult.success(carPartsShopAuditService.deleteCarPartsShopAuditByCarPartsShopAuditIds(carPartsShopAuditIds));
    }

    /**
     * 是否通过汽配商申请
     */
    @ApiOperation("是否通过商家入住申请")
    @PreAuthorize("@ss.hasPermi('sho:carPartsShopAudit:isPass')")
    @Log(title = "商家入住审核", businessType = BusinessType.UPDATE)
    @PostMapping("/isPass")
    public ApiResult isPassCarPartsShopAudit(@RequestBody IsPassCarPartsShopAuditParam isPassCarPartsShopAuditParam) {
        return carPartsShopAuditService.isPassCarPartsShopAudit(isPassCarPartsShopAuditParam);
    }

    /**
     * 批量通过审核
     */
    @ApiOperation("批量通过审核")
    @PreAuthorize("@ss.hasPermi('sho:carPartsShopAudit:AllPass')")
    @Log(title = "商家入住审核", businessType = BusinessType.UPDATE)
    @PostMapping("/allPass/{carPartsShopAuditIds}")
    public ApiResult allPass(@PathVariable Long[] carPartsShopAuditIds) {
        return carPartsShopAuditService.allPassPassCarPartsShopAudit(carPartsShopAuditIds);
    }
}
